package com.hk.yajin.function;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.hk.yajin.R;
import com.hk.yajin.base.BaseActivity;
import com.hk.yajin.function.videos.fragment.CommonVideoListFragment;
import com.hk.yajin.function.videos.fragment.VideoListFragment;


public class ContainerActivity extends BaseActivity implements View.OnClickListener {
    //栏目cid，栏目类别tid,类别名称
    private FragmentManager fm;
    private FragmentTransaction ft;
    private Fragment childFragment;

    private TextView tv_title;
    private String tag;
    private int id;
    public static final String FRAGMENT_TAG = "tag";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_column_container);
        initView();
        initFragment();

    }

    private void initView() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setBackgroundColor(getResources().getColor(R.color.white));
        toolbar.setTitle("");
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_title.setText("容器");
    }

    private void getFragmentByTag() {
        tag = getIntent().getStringExtra(FRAGMENT_TAG);
        id = getIntent().getIntExtra(ID, 0);
        if (tag.equals("s_id")) {
            tv_title.setText("系列视频");
            childFragment = new CommonVideoListFragment();
            Bundle data = new Bundle();
            data.putInt(CommonVideoListFragment.TYPE_ID, id);
            childFragment.setArguments(data);
        }
    }

    private void initFragment() {
        getFragmentByTag();

        if (childFragment == null) {
            finish();
            return;
        }
        fm = getSupportFragmentManager();
        ft = fm.beginTransaction();
        ft.add(R.id.lly_column_container, childFragment);
        ft.commit();
    }

    @Override
    public void onClick(View v) {

    }
}
